package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.gdms.model.Course;
import com.zr.gdms.service.StudentService;
import com.zr.gdms.serviceimpl.StudentServiceImpl;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @author  shichongming
 * @E-mail: 
 * @date 创建时间：2017年5月26日 上午11:27:51 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return  
 */

public class ShowCourseControllerSCM extends HttpServlet{
				StudentService stu=new StudentServiceImpl();
	
	
	//获取没有被选的课题
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		super.doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		req.setCharacterEncoding("utf-8");
	    resp.setCharacterEncoding("utf-8");	  

		 
	    //分页
	    int p = Integer.parseInt(req.getParameter("page"));
	
	    int rows = Integer.parseInt(req.getParameter("rows"));
	  	  
	    int page=(p-1)*rows;
	    int s=stu.sfindCount("false");
	    JSONArray js=stu.sfindCourseFenYe("false", page, rows);
	    JSONObject j=new JSONObject();
	    j.put("total",s);
	    j.put("rows",js);
	    PrintWriter pw=resp.getWriter();
		pw.write(j.toString());
	    
	
	}
	
	
	
	
	
	
	
	
	
}
